<?php
namespace app\controller;

use app\BaseController;
use app\common\Eldata;

class Api extends BaseController
{
    public function getWechatQrcode()
    {
        if($this->request->action()=='POST'){

        }
    }

    public function getWechatNumber()
    {

        if($this->request->action() == 'POST'){

        }else{
            return 'this api is get the wechat number';
        }
    }

    public function RecordKeyWord()
    {
        if($this->request->action() == 'POST'){

        }
    }
    public function RecordVisitor()
    {
        if($this->request->action() == 'POST'){

        }
    }

    public function relogin()
    {
      return json_encode(array(
          'status' => 105,
          'message' => '请登录或重新登录',
      ));
    }

    public function recordViewData()
    {
        if($this->request->action() == 'GET'){
            $insert_params= [
                'index' => $indexName,
                'type' => $indexType,
                'id' => $indexID,
                'body' => $indexBody
            ];

            $indexName='view_datas';

            if($this->request->param('type')==0){
                $indexType = 'click';
            }else {
                $indexType = 'copy';
            }

            $indexID = $this->request->ip();
            $indexBody=[
                'view_search_url' => $this->request->param('rf'),
                'view_copy_data' => $this->request->param('ct'),
                'view_cur_url' => $this->request->param('lh'),
                'view_platform' => $this->request->param('pf'),
                'view_endpoint' => $this->request->param('ws'),
                'view_keyword' => $this->request->param('st'),
                'view_screen' => $this->request->param('sc'),
                'view_lat' => $this->request->param('lat'),
                'view_lon' => $this->request->param('lon'),
                'view_nation' => $this->request->param('nation'),
                'view_province' => $this->request->param('province'),
                'view_city' => $this->request->param('city'),
                'view_time' => time()
            ];

            return $this->app->view_datas->upsertDoc($indexName, $indexID, $indexBody);
        }
    }
}
